#ifndef PLACEWAY_H
#define PLACEWAY_H
#include <QHBoxLayout>
#include <QString>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
#include <QLabel>
#include "common.h"
class HqLabel;
class MyPlaceWay : public QHBoxLayout
{
public:
    MyPlaceWay();
    ~MyPlaceWay();
    virtual void SetWidget(HqLabel*, QString, QString, QString) = 0;
    virtual void ResetHqtext(QString) = 0;
    virtual void SetParam(QString, QString, QString) = 0;

protected:
    QLabel *m_label1;
    QLabel *m_label2;
    HqLabel *m_parent;
};

class MyPlaceWayPh : public MyPlaceWay
{
public:
    MyPlaceWayPh();
    virtual ~MyPlaceWayPh();
    virtual void SetParam(QString text, QString qss1, QString qss2);
    virtual void SetWidget(HqLabel*, QString, QString, QString);
    virtual void ResetHqtext(QString text);
};

class MyPlaceWayPv1 : public MyPlaceWay
{
public:
    MyPlaceWayPv1();
    virtual ~MyPlaceWayPv1();
    virtual void SetParam(QString text, QString qss1, QString qss2);
    virtual void SetWidget(HqLabel*, QString, QString, QString);
    virtual void ResetHqtext(QString text);
private:
    QGraphicsScene *m_scene1;
    QGraphicsScene *m_scene2;
    QGraphicsView *m_view1;
    QGraphicsView *m_view2;
};

class MyPlaceWayPv2 : public MyPlaceWay
{
public:
    MyPlaceWayPv2();
    virtual ~MyPlaceWayPv2();
    virtual void SetParam(QString text, QString qss1, QString qss2);
    virtual void SetWidget(HqLabel*, QString, QString, QString);
    virtual void ResetHqtext(QString text);
private:
    QGraphicsScene *m_scene1;
    QGraphicsScene *m_scene2;
    QGraphicsView *m_view1;
    QGraphicsView *m_view2;
};

class MyPlaceWayPANY : public MyPlaceWay
{
public:
    MyPlaceWayPANY(int digree);
    virtual ~MyPlaceWayPANY();
    virtual void SetParam(QString text, QString qss1, QString qss2);
    virtual void SetWidget(HqLabel*, QString, QString, QString);
    virtual void ResetHqtext(QString text);

private:
    QGraphicsScene *m_scene;
    QGraphicsView *m_view;
    QGraphicsProxyWidget *m_pw;
    int m_digree;
};

class CreatePlaceWayLayout
{
public:
    MyPlaceWay* CreateLayout(QString type)
    {
        if (type == "PH")
        {
            return (new MyPlaceWayPh());
        } else if (type == "PV_CH_LEFT" || type == "PV")
        {
            return (new MyPlaceWayPv1());
        } else if (type == "PV_CH_RIGHT")
        {
            return (new MyPlaceWayPv2());
        } else if (type.contains("P") && type.size() > 1)
        {
            int digree = type.right(type.size() - 1).toInt();
            if (digree == 0)
                return (new MyPlaceWayPh());

            if (digree < 90 && digree > -90)
            {
                MyPlaceWay *p = new MyPlaceWayPANY(digree);
                return p;
            }
        }

        return (new MyPlaceWayPh());
    }
};

#endif // PLACEWAY_H
